package cn.school.mybatis.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@WebFilter("")
public class RoleFilter implements Filter {
    public void destroy() {
    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
//        System.err.println("开始权限检查.....");
//        HttpServletRequest httpReq= (HttpServletRequest) req;
//        //访问地址
//        String path=httpReq.getServletPath();
//        if (path.equals("/doAdminLoginServlet")||path.equals("/AdminLTEdemo01/s_login/login.jsp")){
//            System.err.println(path+"这个不查.....");
//            chain.doFilter(req, resp);
//            return;
//        }
//        if (httpReq.getSession().getAttribute("USER_LOGIN")==null){
//            System.err.println(path+"检查到未登录.....");
//         httpReq.getRequestDispatcher("/AdminLTEdemo01/s_login/login.jsp").forward(req,resp);
//         return;
//        }
        System.err.println("一切正常放行.....");
        chain.doFilter(req, resp);
    }

    public void init(FilterConfig config) throws ServletException {

    }

}
